package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TbNetAttackMapper;
import com.ruoyi.system.domain.TbNetAttack;
import com.ruoyi.system.service.ITbNetAttackService;

/**
 * 网络攻击表Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@Service
public class TbNetAttackServiceImpl implements ITbNetAttackService 
{
    @Autowired
    private TbNetAttackMapper tbNetAttackMapper;

    /**
     * 查询网络攻击表
     * 
     * @param netId 网络攻击表主键
     * @return 网络攻击表
     */
    @Override
    public TbNetAttack selectTbNetAttackByNetId(String netId)
    {
        return tbNetAttackMapper.selectTbNetAttackByNetId(netId);
    }

    /**
     * 查询网络攻击表列表
     * 
     * @param tbNetAttack 网络攻击表
     * @return 网络攻击表
     */
    @Override
    public List<TbNetAttack> selectTbNetAttackList(TbNetAttack tbNetAttack)
    {
        return tbNetAttackMapper.selectTbNetAttackList(tbNetAttack);
    }

    /**
     * 新增网络攻击表
     * 
     * @param tbNetAttack 网络攻击表
     * @return 结果
     */
    @Override
    public int insertTbNetAttack(TbNetAttack tbNetAttack)
    {
        //先查询最大字段
        String maxIDing = tbNetAttackMapper.selectMaxID();//查询数据库的最大id
        if (maxIDing == null){
            maxIDing = "NetAttack_1";
            tbNetAttack.setNetId(maxIDing);
        }else {
            String maxID = maxIDing.substring(10);//截取后面的数字
            int maxIDint = Integer.parseInt(maxID);
            maxIDint++;
            maxID = "NetAttack_"+maxIDint;
            tbNetAttack.setNetId(maxID);
        }
        tbNetAttack.setCreateTime(DateUtils.getNowDate());
        return tbNetAttackMapper.insertTbNetAttack(tbNetAttack);
    }

    /**
     * 修改网络攻击表
     * 
     * @param tbNetAttack 网络攻击表
     * @return 结果
     */
    @Override
    public int updateTbNetAttack(TbNetAttack tbNetAttack)
    {
        return tbNetAttackMapper.updateTbNetAttack(tbNetAttack);
    }

    /**
     * 批量删除网络攻击表
     * 
     * @param netIds 需要删除的网络攻击表主键
     * @return 结果
     */
    @Override
    public int deleteTbNetAttackByNetIds(String[] netIds)
    {
        return tbNetAttackMapper.deleteTbNetAttackByNetIds(netIds);
    }

    /**
     * 删除网络攻击表信息
     * 
     * @param netId 网络攻击表主键
     * @return 结果
     */
    @Override
    public int deleteTbNetAttackByNetId(String netId)
    {
        return tbNetAttackMapper.deleteTbNetAttackByNetId(netId);
    }
}
